package com.xqls.dal.dao.mybatis;

import com.xqls.dal.dao.CompanyDao;
import com.xqls.dal.model.Company;
import com.xqls.dal.model.CompanyExample;
import com.xqls.dal.service.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class CompanyDaoImpl implements CompanyDao{

	@Autowired private CompanyMapper mapper;
	
	@Override
	public boolean insert(Company record){
		return mapper.insertSelective(record)>0;
	}
	
	@Override
	public boolean update(Company record){
		return mapper.updateByPrimaryKey(record)>0;
	}

	
	@Override
	public boolean deleteList(List<Integer> keys){
		CompanyExample example = new CompanyExample();
		example.createCriteria().andCompanyIdIn(keys) ;
		return mapper.deleteByExample(example)>0;
	}
	
	@Override
	public boolean deleteByBlockId(Integer blockId){
		CompanyExample example = new CompanyExample();
		example.createCriteria().andBlockIdEqualTo(blockId);
		return mapper.deleteByExample(example)>0;
	}
	
	@Override
	public Company queryByKey(Integer key){
		return mapper.selectByPrimaryKey(key);
	}
	
	@Override
	public List<Company> queryByExample(CompanyExample example){
		return mapper.selectByExample(example);
	}
	
	@Override
	public List<Map<String, Object>> queryByBlockOrType(Map<String, Object> map){
		return mapper.selectByBlockOrType(map);
	}
}
